/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.iec.edp.caf.rpc.test.client;

import io.iec.edp.caf.commons.event.config.EventListenerSettings;
import io.iec.edp.caf.rpc.api.event.RpcClientEventBroker;
import io.iec.edp.caf.rpc.api.event.RpcClientEventManager;
import io.iec.edp.caf.rpc.api.properties.RPCConfigurationProperties;
import io.iec.edp.caf.rpc.api.service.CAFRpcClient;
import io.iec.edp.caf.rpc.api.service.RpcClient;
import io.iec.edp.caf.rpc.client.RpcClassHolder;
import io.iec.edp.caf.rpc.registry.api.RpcDefinitionRegistry;
import io.iec.edp.caf.rpc.test.impl.RpcTest;
import io.iec.edp.caf.rpc.test.impl.RpcTestImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


import static org.mockito.Mockito.mock;

@Configuration
@ComponentScan({"io.iec.edp.caf.rpc"})
@EnableConfigurationProperties({
        RPCConfigurationProperties.class
})
public class RpcClientTestConfig {

    @Bean
    public RpcTest createRpcTest(){
        return  new RpcTestImpl();
    }

    @Bean
    public RpcClientEventManager createRpcClientEventManager(){
        return new RpcClientEventManager();
    }

    @Bean
    public RpcClientEventBroker createRpcClientEventBroker(RpcClientEventManager manager,EventListenerSettings settings){
        return new RpcClientEventBroker(manager,settings);
    }

    @Bean
    public EventListenerSettings createEventListenerSettings() {
        return mock(EventListenerSettings.class);
    }

    @Bean
    public RpcDefinitionRegistry createRpcDefinitionRegistry() {
        return mock(RpcDefinitionRegistry.class);
    }


    @Bean
    public RpcClient createRpcClient() {
        return mock(RpcClient.class);
    }

    @Bean
    public RpcClassHolder createRpcHolder(RpcClient client) {
        return new RpcClassHolder(client);
    }

    @Bean
    public CAFRpcClient createCAFRpcClient() {
        return mock(CAFRpcClient.class);
    }

}
